home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Essential Home & Business Collection
/
The Essential Home & Business Collection.iso
/
26
/
3
/
2
/
PTOUCH.ZIP
/
TOUCH.BAS
< prev
Wrap
BASIC Source File
|
1990-04-07
|
4KB
|
115 lines
' this program is being used to develop the ability to read, save and
' re-write the file date back to the directory. in this way, the
' program will apear un-altered. When used, we will first get the
' date and time, and then close the file. when done altering and
' closing the file, we will re-open and replace the current date and time
' with the original date and time.
' PowerBASIC version
' TOUCH.PBU
$Compile UNIT
Defint a-z
EXTERNAL FILEDate&,FileTime&,ErrorCode
%True = -1
%False = 0
'┌───────────────────────────────────────────────────────────────────────────┐
'│ REGNAMES.INC │
'│ │
'│ This file is to be used as a $INCLUDE file whenever you use the CALL │
'│ INTERRUPT statement in your PowerBASIC program. The file contains │
'│ named constants that represent the registers the CALL INTERRUPT statement │
'│ can manipulate. │
'│ │
'│ In order to use this file include it in your programs using the $INCLUDE │
'│ metastatement: │
'│ │
'│ $INCLUDE "REGNAMES.INC" │
'│ │
'└───────────────────────────────────────────────────────────────────────────┘
%FLAGS = 0
%AX = 1
%BX = 2
%CX = 3
%DX = 4
%SI = 5
%DI = 6
%BP = 7
%DS = 8
%ES = 9
SUB Touch(FileName$,WayToGo$) PUBLIC
'*********************************************************
'* *
'* Name: Touch *
'* Purpose: To get the current file time and date, and *
'* save it. It will then be used to rewrite *
'* back to the directory. *
'* Application: PowerBasic file invisible file updates *
'* By: Barry Erick *
'* Date: June 1, 1987, Jan 20,1990 *
'* Altered: Registers 0,1,2,3,4,8 (Flags,AX,BX,CX,DX,DS) *
'* *
'*********************************************************
SHARED FileDate&,FileTime&,ErrorCode 'Pass them on for later use
DirectionError = %False
IF UCase$(WayToGo$) = "SET" THEN
WayToGo = Asc(">")
ELSE
WayToGo = ASC("<")
END IF
FileName$=FileName$ +CHR$(0) ' Tag on a Zero to make it a ASCIIZ
'
REG %AX,&H3D00 'open the file for read to then get date and time
' ah = 3d, al = 0..read only
REG %DX,StrPtr(Filename$)
REG %DS,StrSeg(FileName$)
CALL INTERRUPT &H21
CarryFlag = REG(%FLAGS)MOD &HFFFE
Handle = REG(1) MOD 256
IF WayToGo = asc(">") then goto SetFileTimeDate
IF WayToGo = asc("<") Then goto GetFileTimeDate
DirectionError = %True ' Parameter wrong
Goto CloseIt ' so tell and close it...delete once working
GetFileTimeDate:
REG %AX,&H5700 ' get date,time ah=57, al = 0
REG %BX,Handle
CALL INTERRUPT &H21
FileTime& = REG(%CX)
FileDate& = REG(%DX)
GOTO CloseIt
SetFileTimeDate:
'set file date
REG %AX,&H5701 ' set date,time ah=57, al = 1
REG %BX,Handle
REG %CX,FileTime&
REG %DX,FileDate&
CALL INTERRUPT &H21
IF REG(%FLAGS) MOD &HFFFE = 1 then goto setError
GOTO CloseIt
SetError:
errcode = REG(1) MOD 256 'AL
if ErrCode = 1 then print "Bad Function Code (not 1 or 0)":goto CloseIt
if ErrCode = 6 then print "Bad handle passed": GoTO CloseIt
? "I got and error on setting, but I don't know what it is..";errCode
GOTO CloseIt
CloseIt:
If DirectionError then
? " Parameter Error.... must be GET or SET "
end if
' file is open.... close it for now
REG %AX,&H3E00
REG %BX,Handle
CALL INTERRUPT &H21
END SUB